Ext.define('AM.view.Viewport', {
    extend: 'Ext.container.Viewport',
//    maxWidth: 1024,
	requires: ['AM.view.modules.westMenu.WestPanelScope','AM.view.modules.westMenu.NorthPanelScope','PJ.view.messagenotification.Frame'],
    layout: 'border',
    
    items: [{
        region: 'center',
        xtype: 'tabpanel',
        id: "viewTab",
        plugins: Ext.create('Ext.ux.TabCloseMenu', {
            closeAllTabsText: modules_lang.closeText[0],
            closeOthersTabsText: modules_lang.closeText[1],
            closeTabText: modules_lang.closeText[2]
        }),
//        items: [{
//            title: modules_lang.welcome,
////            title: '最新通知和提醒',
//            itemId: 'welcome',
//            html: '<div id="welcomeHtml" class="welcomeMainBg"><div class="welcomeBg"></div></div>',
//            xtype: 'messagenotificationFrame'
//        }],
        listeners: {
        	tabchange: function(tabpanel, newPanel){
        		if(newPanel.itemId != 'welcome'){
        			//菜单--列表
        			if(newPanel.store){
        				newPanel.getStore().load();
        			}
        			if(newPanel.url == "unitsignup.List"){
        				newPanel.userNum();//人数统计
        			}
        			//菜单--tab页签
        			var tabGrid = newPanel.items.items[0];
        			if(tabGrid.activeTab){
        				tabGrid.activeTab.getStore().load();
            			var gridUrl = tabGrid.activeTab.url;
            			var gridUrlStr = gridUrl.substring(0,gridUrl.indexOf("."));
        				if(gridUrlStr == "centralorganizationplaces" || gridUrlStr == "workingcommitteeadjustmentplaces" ){
        					tabGrid.activeTab.userNum();//人数统计
        				}
        			}
        		}
        	}
        }
    }, {
        region: 'north',
        xtype: 'northPanelScope'
//        xtype: 'northPanel'
    }, {
        region: 'west',
        width: 180,
        id: "westTree",
        xtype: 'westPanelScope',
//        xtype: 'westPanel',
        collapsible: true
    }],
    listeners: {
        afterrender: function(){
        	//查询当前角色，只有一，二级管理员才有权限接收提醒
        	Ext.Ajax.request({
        	    url : findRoleUrl,  //后台请求地址
        	    success : function(record){
        	    	var datas=Ext.JSON.decode(record.responseText).data;
        	    	var items;
	    			var pan = Ext.getCmp('viewTab');  
    	    		if(datas[0].value!='xueyuan'){
    	    			items={
    	    	            title: modules_lang.welcome,
    	    	            itemId: 'welcome',
    	    	            xtype: 'messagenotificationFrame'
    	    	        };
    	    			
    	    		}else{
    	    			var items={
    	    	            title: modules_lang.welcome,
    	    	            itemId: 'welcome',
    	    	            html: '<div id="welcomeHtml" class="welcomeMainBg"><div class="welcomeBg"></div></div>'
    	    			};
    	    		}
	    			pan.removeAll(true);
	    			pan.add(items);
	    			pan.doLayout();//刷新
    	    	}
        	});
            new Ext.LoadMask(Ext.getCmp("viewTab"), {
                msg: orchid_lang.promptWindowInfo.loadingText,
                id: 'loadingMask'
            });
        }
    }
});
